#include <QMouseEvent>
#include "tab-bar.h"

TabBar::TabBar (QWidget *parent) :
    QTabBar(parent)
{
}

void TabBar::mouseDoubleClickEvent (QMouseEvent *event)
{
    if (tabAt(event->pos()) != count()-1)
        emit doubleClicked();
}

void TabBar::mousePressEvent (QMouseEvent *event)
{
    if (event->button() == Qt::LeftButton && tabAt(event->pos()) == count()-1 && count() > 1)
    {
        emit addTabRequested();
        event->accept();
    }
    else
    {
        QTabBar::mousePressEvent(event);
    }
}
